import { Node } from "cc";

/*** 回调参数对象定义 */
export interface UICallbacks {
    onAdded?: (uuid: string, node: Node, params: any) => void,
    onRemoved?: (node: Node | null, params: any) => void,

    /** 
     * 
     * 如果指定onBeforeRemoved，则removeCallback必须调用，否则节点不会被正常删除。
     * 比如希望节点做一个FadeOut然后删除，则可以在`onBeforeRemoved`当中播放action动画，动画结束后调用removeCallback
     * 
     * */
    onBeforeRemove?: (node: Node, removeCallback: Function) => void
}



export enum ViewType {
    Arena = 1,
    Decoration = 2,
    UI = 3,
    PopUp = 4,
    Alert = 5,
    Tips = 6,
    Guide = 7
}

export interface ViewConfig {
    bundle?: string;
    type: ViewType;
    prefab: string;
}

export class ViewParams {
    /** 界面唯一标识 */
    public uuid!: string;
    /** viewconfig */
    public config!: ViewConfig;
    /** 传递给打开界面的参数 */
    public payload: any | null;
    /** 窗口事件 */
    public callbacks!: UICallbacks | null;
    /** 是否在使用状态 */
    public valid: boolean = true;
    /** 界面根节点 */
    public node: Node | null = null;
    /** prefab path */
    public prefabPath: string = null;

}